import {showMessage} from '../../js/my-plugin'
import {_TOTAL_PATH_} from '../../js/my-core'

// 获取追番列表
export const getCollectList = function (_this) {
  // if (_this.$store.state.user == null || _this.$store.state.user === '') {
  //   showMessage('您还没有登录', 0)
  //   _this.$router.push('/login')
  //   return
  // }
  _this.$axios({
    method: 'get',
    url: '/api/anime/get_collect_list',
    headers: {Authorization: _this.$store.state.authorization}
  })
    .then((res) => {
      if (res.data.code === 200) {
        _this.videoList = []
        let i = 0
        if (res.data.data == null) {
          showMessage('您还没有追番哦', 1)
          return
        }
        for (let item of res.data.data) {
          let it = {id: i, data: {count: item.count, cover: item.cover, href: _TOTAL_PATH_[0] + item.id, name: item.name, allNum: item.allNum, refreshNum: item.refreshNum, status: item.status}}
          _this.videoList.push(it)
          i++
        }
      } else if (res.data.code === 203) {
        showMessage('您还没有登录', 0)
        _this.$router.push('/login')
      }
    })
    .catch((error) => {
      console.log(error)
      showMessage('登陆失败，无法连接服务器', 0)
    })
}
